<%@page import="javax.security.auth.message.callback.PrivateKeyCallback.Request"%>
<%@page import="com.situ.web.servlet.Teacher"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.css"/>
</head>
<body>

	<%
	   // jsp页面中内置了request对象，可以直接使用
		ArrayList<Teacher> list = (ArrayList<Teacher>)request.getAttribute("list");
	%>

	<a class="btn btn-primary" href="<%=request.getContextPath()%>/teacher_insert.jsp">添加</a>
	<table class="table table-striped table-bordered table-hover table-condensed">
		<tr>
			<th>ID</th>
			<th>名字</th>
			<th>年龄</th>
			<th>薪水</th>
			<th>删除</th>
			<th>更改</th>
		</tr>
		<%
			for (Teacher teacher : list) {
		%>
				<tr>
					<td><%=teacher.getId()%></td>
					<td><%=teacher.getName()%></td>
					<td><%=teacher.getAge()%></td>
					<td><%=teacher.getSalary()%></td>
      				
					<td><a href="javascript:void(0)" onclick="deleteById(<%=teacher.getId()%>)">删除</a></td>
					<td><a href="<%=request.getContextPath()%>/teacher?method=selectTeacher&id=<%=teacher.getId()%>">更改</a></td>
					
					<!-- request.getContextPath() 返回当前项目名字 -->
				</tr>
				
		<%
			}
		%>
		
	
	</table>
	<script type="text/javascript">
		function deleteById(id) {
			var isDel = confirm("您确认要删除么？");
			if (isDel) {
				location.href = "/java1912Web/teacher?method=deleteById&id=" + id;
			}
		}
	</script>
	

</body>
</html>